package xyz.doikki.dkplayer.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class UserBean {
    public String user;
    public String psd;

    public UserBean() {
    }

    public UserBean(String user, String psd) {
        this.user = user;
        this.psd = psd;
    }

    public static List<UserBean> arrayUserBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<UserBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserBean userBean = (UserBean) o;
        return user.equals(userBean.user) && psd.equals(userBean.psd);
    }

    @Override
    public int hashCode() {
        return Objects.hash(user, psd);
    }
}
